package com.dzsw.mybatisx.gen.util;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Objects;

public class MyTypeConvert {

    public String convert(String type) {
        if (type == null) {
            return "";
        }
        type = type.toUpperCase();
        if (type.startsWith("INT")) {
            return "INTEGER";
        } else if (type.startsWith("VARCHAR")) {
            return "VARCHAR";
        } else if (type.startsWith("TEXT")) {
            return "VARCHAR";
        } else if (type.startsWith("DECIMAL")) {
            return "DECIMAL";
        } else if (type.startsWith("TINYINT(1)")) {
            return "TINYINT(1)";
        } else if (type.startsWith("BIGINT")) {
            return "BIGINT";
        } else if (type.startsWith("DATETIME")) {
            return "TIMESTAMP";
        } else {
            return type;
        }
    }

    public String initialLowercase(String word) {
        if(Character.isLowerCase(word.charAt(0))) {
            return word;
        } else {
            return Character.toLowerCase(word.charAt(0)) +
                    word.substring(1);
        }
    }

}
